package com.example.framework2002a.view.activity;

import androidx.appcompat.app.AppCompatActivity;
import androidx.databinding.DataBindingUtil;
import androidx.lifecycle.Observer;
import androidx.lifecycle.ViewModelProvider;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.StaggeredGridLayoutManager;

import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.provider.CalendarContract;
import android.view.View;

import com.example.framework2002a.R;
import com.example.framework2002a.adapter.FoodAdapter;
import com.example.framework2002a.databinding.ActivityFoodBinding;
import com.example.framework2002a.view.view.Main2Activity;
import com.example.lib_core.bean.FoodBean;
import com.example.lib_core.factory.FragFactory;
import com.example.lib_core.factory.FragViewModel;
import com.fhz.utilsfhz.ApiResponse;

import java.util.ArrayList;
import java.util.List;

public class FoodActivity extends AppCompatActivity {

    private ActivityFoodBinding binding;
    private FragViewModel fragViewModel;
    private List<FoodBean> foodBeans = new ArrayList<>();
    private FoodAdapter foodAdapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_food);

        binding = DataBindingUtil.setContentView(this,R.layout.activity_food);

        fragViewModel = new ViewModelProvider(this,new FragFactory()).get(FragViewModel.class);
//        fragViewModel.getFood().observe(this, new Observer<ApiResponse<List<FoodBean>>>() {
//            @Override
//            public void onChanged(ApiResponse<List<FoodBean>> listApiResponse) {
//                foodBeans.addAll(listApiResponse.getData());
//
//                foodAdapter = new FoodAdapter(foodBeans);
//                binding.foodRv.setAdapter(foodAdapter);
//                binding.foodRv.setLayoutManager(new StaggeredGridLayoutManager(3,StaggeredGridLayoutManager.VERTICAL));
//            }
//        });

        binding.foodNext.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(new Intent(FoodActivity.this, Main2Activity.class));
            }
        });
    }
}